<template>
  <div class="login-container">

  </div>
</template>

<script>
import { isvalidUsername } from '@/utils/validate'

export default {
  name: 'Login',
  data() {
   
    return {
      loginForm: {
        username: '',
        password: '',
				loginKey: ''
      },
    
      
      pwdType: 'password',
      redirect: undefined,
			loginKey: '',
    }
  },
  watch: {
    $route: {
      handler: function(route) {
        this.redirect = route.query && route.query.redirect;
				this.loginKey=route.query.loginKey;
      },
      immediate: true
    }
  },
  methods: {
    showPwd() {
      if (this.pwdType === 'password') {
        this.pwdType = ''
      } else {
        this.pwdType = 'password'
      }
    },
    handleLogin() {
          this.$store.dispatch('Login', this.loginForm).then((res) => {
						console.log(res)
						this.loading = false
						if(res.data.success==true){
							this.$router.push({ path: this.redirect || '/' })
						}else{
							this.$message.error("登录失败");
						}

          }).catch(() => {
          })
    },
  },
	 created() {
	  if(this.loginKey!=undefined&&this.loginKey!=null&&this.loginKey!=''){
			this.loginForm.loginKey=this.loginKey;
			this.handleLogin();
		}
	},
}
</script>

<style rel="stylesheet/scss" lang="scss">
$bg:#2d3a4b;
$light_gray:#eee;

/* reset element-ui css */
.login-container {
  .el-input {
    display: inline-block;
    height: 47px;
    width: 85%;
    input {
      background: transparent;
      border: 0px;
      -webkit-appearance: none;
      border-radius: 0px;
      padding: 12px 5px 12px 15px;
      color: $light_gray;
      height: 47px;
      &:-webkit-autofill {
        -webkit-box-shadow: 0 0 0px 1000px $bg inset !important;
        -webkit-text-fill-color: #fff !important;
      }
    }
  }
  .el-form-item {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    color: #454545;
  }
}

</style>


